<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	response.setContentType("text/html;charset=utf-8");   
	response.setCharacterEncoding("utf-8"); 
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>活动管理</title>
<link href="<%=path%>/favicon.ico" rel="shortcut icon">

<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/public.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/activity.css" />


	
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css">
<link href="<%=path%>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
<link href="<%=path%>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="<%=path%>/hplus/css/animate.min.css" rel="stylesheet">
<link href="<%=path%>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">	
<style type="text/css">
.table{
	font-size:14px;
}
 .table tbody tr td{
 	padding:0;
 }
 tbody tr td ol{
 	margin-bottom:0;
 }
  tbody tr td ol li{
	height: 50px;
	line-height: 50px;
	border-bottom: 1px solid #eee;
}
tbody tr td .s_none_line li{
	border-bottom: none;
}
 tbody tr td ol li:last-child{
	border-bottom: none;
}

tbody tr td ul li{
	height: 37.5px;
	line-height: 37.5px;
}

 tbody tr td .k_ol li{
	line-height: 18px;
	border-bottom: none;
	padding-top: 6px;
}
 
 
 </style>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
	
		<div class="container-fluid">
			<div class="row">
				<div hidden="" class="col-md-12">
				 	<div class="ibox">
					    <div class="ibox-content text-right">
					      <h3>
								<span>
										<a href="<%=path%>/api/bm/ui/microPortal"style="margin-right: 15px;"><font color="#1ab394">酷门户</font></a>
										<button id="intent_crate_activity" type="button" class="btn btn-primary">一分钟快速创建活动</button>
								</span>
							</h3>
					    </div>
			   		</div> 
				</div>
				
				<div class="col-md-12" style="margin-bottom:20px">
					<form role="form" action="" class="form-inline">
					    <div class="col-md-3 form-group">
					       <label>关键字</label>
					      <input style="width:160px;" class="form-control" id="input_search_key" type="text" placeholder="输入搜索关键字" maxlength="12" onblur="checkLength(this)"/>
					    </div>
					    <div class="col-md-2 form-group">
					       <select id="select_ratio" onchange="select_change(this)" class="form-control" name="trade_type">
					         <option value="0">全部</option>
					         <option value="1">平均转化率</option>
					       </select>
					    </div>
					    <div class="col-md-1 form-group">
					        <select id=select_where onchange="select_change(this)" class="form-control" name="trade_type">
					         <option value="0">全部</option>
					         <option value="1">大于</option>
					         <option value="2">小于</option>
					        </select>
					    </div>
					    <div class="col-md-1 form-group">
					    	<input style="width:80px;" class="form-control" id="ratio_vaule" type="text" placeholder="数值(%)" maxlength="4" onblur="checkLength(this)">					    
					    </div>
					     <div class="col-md-2 form-group">
					       <label>状态</label>
					       <select id="select_state" onchange="select_change(this)" class="form-control" name="trade_type">
					         <option value="0">全部</option>
					         <option value="1">启用</option>
					         <option value="2">停用</option>
					       </select>
					    </div>
					    
					    <div class="col-md-1 form-group">
					        <button type="button" id="search_keyword" class="btn btn-primary">搜索</button>
					    </div>
					    <div class="col-md-1 form-group" style="float: right;margin-right: 15px;">
					         <shiro:hasPermission name="markting_activity_h5:create">
					         <button type="button" class="btn btn-info" onclick="window.location.href='<%=path%>/view/ui/chooseActivityTemplate'">创建活动</button>
					         </shiro:hasPermission>
					    </div>
				    </form> 
				</div>
				
				<div class="col-md-12">
					<table class="table table-bordered table-hover white-bg ">
						<thead>
							<tr>
								<th>活动概览</th>
								<!-- <th>活动标签</th> -->
								<th>统计值</th>
								<th>状态</th>
								<th>分享<br />渠道
								</th>
								<th>打开数</th>
								<th>提交表<br />单数
								</th>
								<th>转化比例</th>
								<th>一次人脉</th>
								<th>二次人脉</th>
								<th>累计核<br />销金额
								</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="activity_list">
						</tbody>
					</table>
					<div id="content_empty"  hidden="" class="form-group white-bg" style="text-align:center;padding:200px 0;margin:0;">   
                        <p id="emptyTitle">您还没有创建活动，请快创建活动吧</p>
                        <button id="emptyBtn" class="btn btn-primary" onclick="window.location.href='<%=path%>/view/ui/chooseActivityTemplate'">创建活动</button>
                    </div>
				</div>

				<div class="m_xpages"  style="width: 100%; margin: 0;">
					<div class="mian">
						<span>显示行数</span> <select><option>5</option>
							<option>10</option>
							<option>20</option></select> <span>共0条</span> <span>0/0页</span> <a
							href="javascript:;" class="prev">上一页</a> <a href="javascript:;"
							class="next">下一页</a> <span>前往</span> <input id="input_page" type="text" value="1"
							class="text"> <span>页</span>
					</div>
				</div>

				<div class="col-md-12 s_hot_box fix">
					<h6 >
						推荐最热模板<span>Hot</span>
					</h6>
					<div id="hot_activity_list" class="fix" style="margin-left: 1.5%;"></div>
				</div>
			</div>
		</div>
	</div>


	
	<div hidden="" class="modal inmodal fade" id="share_modal" tabindex="-1" role="dialog"  aria-hidden="true">
	    <div class="modal-dialog modal-sm">
	        <div class="modal-content">
	            <div class="modal-header">
	                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
	                <h4 class="modal-title">扫一扫立刻分享</h4>
	            </div>
	            <div class="modal-body text-center">
	               <div id="qrcode"></div>
	               <div style="margin-top:15px;margin-left:10px;margin-bottom:20px">
	                   <h5 style="float: left;width:15%;margin-top:10px">链接</h5>
	                   <input id="shortUrl" type="text" class="input form-control" style="float: left;width:55%;" readonly="readonly">
	                   <button id="btnCopy" class="btn btn-primary" type="button" style="float: left;width:25%;margin-left:5%" data-clipboard-action="copy" data-clipboard-target="#shortUrl">复制链接</button>
	               </div>
	                <div style="margin-top:10px;">
	                   <button class="btn btn-primary" type="button" style="width:25%;margin-right: 5%;margin-top: 15px;" onclick="javascript:intentSocialSms();">群发短信</button>
	               </div>
	            </div>
	        </div>
	    </div>
	</div> 
	

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
   	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/lengthlimit.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/dialog-plus.js"></script>
	<script src="<%=path%>/hplus/js/bootstrap.min.js?v=3.3.6"></script>
	<script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
	<script src="<%=path%>/hplus/js/content.min.js?v=1.0.0"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/dialog.js"></script>
	<script src="<%=path%>/js/marketing/public.js"></script>
	<script src="<%=path%>/js/dateUtils.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.js"></script>
	<script type="text/javascript">
	
	 var startIndex = 0;
     var pageSize = 5;
     var currentPage = 1;
     var pageCount = 0;
     var key_word;
     var key_ratio;
     var key_ratio_where="more";
     var ratio_vaule;
     var status="";
     var access_token=$.cookie('access_token');
	 var cid=$.cookie('cid');
	 var uid=$.cookie('uid');
	 var manage_activity_id;
	 var searchFlag = false;
	 
	
	

	
	 $('.k_delect_btn').click(function(){
         $('.s_popup_delect,.issue_delect').show();
     });

     $('.s_cancel,.issue_delect span').click(function(){
         $('.s_popup_delect,.issue_delect').hide();
     });

     $('.k_ty_btn').click(function(){
         $('#suspend,.issue_delect1').show();
     });

     $('.s_cancel1,.issue_delect1 span').click(function(){
         $('.s_popup_delect1,.issue_delect1').hide();
     });

     $('.k_red').click(function(){
         $('.s_popup_delect2,.s_consum').show().delay(3000).fadeOut();
     });

     $('.s_hot_box .s_hot_con').mouseover(function(){
         $(this).find('h4').css({'color':'#03a9f4','text-decoration':'underline'});
         $(this).css({'cursor':'pointer'})
     });

     $('.s_hot_box .s_hot_con').mouseout(function(){
         $(this).find('h4').css({'color':'#666','text-decoration':'none'});
     });
	 //下拉选择值
     function select_change(obj){
     	status=$("#select_state").val();
     	key_ratio_where=$("#select_where").val();
     }
        $(function(){
        	

          $('.selectBox ul li').on('click',function(){
            var text = $(this).text();
            $(this).parents('.select').find('span').text(text);
          });          
          $('.select').on('click',function(){
        	  //e.stopPropagation();
        	  event.stopPropagation(); 
            if($(this).hasClass('selectState')){
              $(this).next().find('img').attr('src','<%=path%>/images/marketing/dropDown.png');
            }else{
              $(this).next().find('img').attr('src','<%=path%>/images/marketing/dropUp.png');
            }
              $(this).toggleClass('selectState');
          });
         <%--  $('body').on('click',function(){
              $('.select').removeClass('selectState');
              $('.dropImg').find('img').attr('src','<%=path%>/images/dropDown.png');
          }) --%>
          $('.select').each(function(index,ele){
              var stateText = $(ele).find('span').text();
              $('.selectBox').eq(index).find('ul li').each(function(indexsLi,elesLi){
                  if($(elesLi).text()==stateText){
                      $(elesLi).addClass('on')
                  }
              });
          });
          
          $('#search_keyword').click(function(){
        	  startIndex=0;
        	  //获取搜索的值
        	  key_word = (document.getElementById('input_search_key')).value;//获取input的节点
        	  ratio_vaule= (document.getElementById('ratio_vaule')).value;//获取input的节点
        	 
        	  if(StringEmpty(ratio_vaule)&&isNaN(ratio_vaule)){
        		  showDialog("转化率只能输入数字");
        		  return ;
        	  }
        	  searchFlag=true;
        	  activityList();
      	  });
          //
          $('#intent_crate_activity').click(function(){
        	  window.location.href="<%=path%>/view/ui/chooseActivityTemplate";
      	  });
          // 启用或者停用操作
          $(document).on('click', '.manageActivity', function() {
				var status=$(this).attr("activityStatus");
			
				if(status==1){
					/* suspendActivity(); */
					manage_activity_id=$(this).attr("activityId");
					suspendDialog();
				}else{
					/* activateActivity($(this).attr("activityId")); */
					manage_activity_id=$(this).attr("activityId");
					activateActivity();
				}
				
			});
          //复制活动
          $(document).on('click', '.copyActivity', function() {
        	  var activity_id=$(this).attr("activityId");
        	  var type=$(this).attr("activity_type");
        	  if(type=="sys"){
        		  window.location.href = "<%=path%>/api/bm/ui/createActivity2?type=copy&activity_id="+activity_id;
        	  }else if(type=="defined_pic"){
        		  window.location.href = "<%=path%>/view/ui/photoAlbum?type=activity_copy&activity_id="+activity_id;
        	  }else if(type=="defined_text"){
        		  window.location.href = "<%=path%>/view/ui/createModel?type=activity_copy&activity_id="+activity_id;
        	  }else if(type=="sys_invitation"){
        		  window.location.href = "<%=path%>/api/bm/ui/invitation01?type=activity_copy&activity_id="+activity_id;
        	  }
        	 
			});
          //编辑活动
          $(document).on('click', '.editActivity', function() {
        	  var activity_id=$(this).attr("activityId");
        	  var type=$(this).attr("activity_type");
        	  lockActivity(type,activity_id);
			  
			});
          //删除活动
          $(document).on('click', '.deleteActivity', function() {
        	  
        	
        	  manage_activity_id=$(this).attr("activityId");
        	  deletedDialog();
			});
          //分享活动
          $(document).on('click', '.shareActivity', function() {
        	  var share_url=$(this).attr("shareUrl");
        	  var status=$(this).attr("activityStatus");
              manage_activity_id = $(this).attr("activityId");
        	  if(status==1){
        		  shareActivity(manage_activity_id);
        	  }else if(status==0){
        		  errorDialog('活动未启用，不能分享！');
        	  }else{
        		  errorDialog('活动未编辑完成，不能分享！');
        	  }
		  });
          $('.J_x_box').click(function () {
              $('.x_popup').show();
             $('.issue').show(); 
         });
         $('.x_popup .issue span').click(function () {
              $('.x_popup').hide();
             $('.issue').hide(); 
         });
          
          
          
          //点击最热模板
          $(document).on('click', '.model_title', function() {
          	var model_id=this.id;
  			var model_type=$(this).attr("model_type");
  			if(model_type=="defined_pic"){
				window.location.href = "<%=path%>/view/ui/photoAlbum?type=model&model_id="+model_id;
			}else{
				window.location.href = "<%=path%>/view/ui/createModel?type=model&model_id="+model_id;
			}
  			});
          
        });
        window.onload = function(){
            activityList();
            hotActivityList();
        }
        //获取活动列表
        function activityList(){
        	var url = "${pageContext.request.contextPath}/activity/ajaxActivityStatisticsList";
        	var keyRatioWhere="";
        	if(key_ratio_where==1){
        		keyRatioWhere="more";
        	}else if(key_ratio_where==2){
        		keyRatioWhere="less";
        	}
        	var param={
    				"startIndex" : startIndex,
    				"pageSize" : pageSize,
    				"keyWord" : key_word,
    				"keyRatio" : key_ratio,
    				"keyRatioWhere" : keyRatioWhere,
    				"status" : status,
    				"ratioVaule":ratio_vaule,
    		};
        	$.post(url,{
        		"paramJson":JSON.stringify(param),
        	   } , function(data) {
    				var msg;
    				if(data.status == 200){
    					msg=data.data;
        				activityhtml(msg);
        				page(data.totalCount);
        				$('#activity_list').show();
    					$('#content_empty').hide();
    					$('.m_xpages').show();
    				}else if(data.error_code=="20028"){
    					loginDialog();
    				}else{
    					if(searchFlag){
    						$('#activity_list').hide();
    						$("#emptyTitle").html("无相关活动！");
    						$('#content_empty').show();
    						$("#emptyBtn").hide();
    						$('.m_xpages').hide();
    						searchFlag=false;
    					}else{
    						$("#emptyTitle").html("您还没有创建活动，请快创建活动吧！");
    						$("#emptyBtn").show();
    						$('#activity_list').hide();
        					$('#content_empty').show();
        					$('.m_xpages').hide();
    					}
    					
    					
    				}
    				
    			});
    		}
        //激活
        function activateActivity() {
			var url = "${pageContext.request.contextPath}/activity/ajaxActivateActivity";
			var manageId="#manageId"+manage_activity_id;
			var statusId="#status"+manage_activity_id;
			var shareManageId="#shareManageId"+manage_activity_id;
			$.post(url, {
				"uid" : uid,
				"cid":cid,
				"access_token" : access_token,
				"id" : manage_activity_id,
			}, function(data) {
				if (data.status == 200) {
					console.log("------->"+shareManageId);
					$(manageId).text("停用");
					$(manageId).attr("activityStatus","1");
					$(shareManageId).attr("activityStatus","1");
					$(shareManageId).attr("class", "shareActivity");
					$(manageId).css("color","#1ab394");
					 $(statusId).html("<p style='color:black;'>正常</p>");
					 successDialog("启用成功","");
				} else {
					errorDialog("启用失败",data.message);
				}
			});
		}
        //停用
		function suspendActivity() {
			var url = "${pageContext.request.contextPath}/activity/ajaxActivitySuspend";
			var manageId="#manageId"+manage_activity_id;
			var shareManageId="#shareManageId"+manage_activity_id;
			var statusId="#status"+manage_activity_id;
			$.post(url, {
				"uid" : uid,
				"access_token" : access_token,
				"activityId" : manage_activity_id,
			}, function(data) {
				if (data.status == 200) {
					console.log("------->"+shareManageId);
					$(manageId).text("启用");
					$(manageId).attr("activityStatus","0");
					$(shareManageId).attr("activityStatus","0");
					$(shareManageId).attr("class", " shareActivity k_gray_enjoy");
					$(manageId).css("color","#ff7469");
					$(statusId).html("<p style='color:red'>停用</p>");
					$('#suspend,.issue_delect1').hide();
					successDialog("停用成功","");
				} else {
					errorDialog("停用失败",data.message);
				}
			});
		}
        //删除
        function deleteActivity() {
			var url = "${pageContext.request.contextPath}/activity/ajaxActivityDelete";
			var lineId="#line"+manage_activity_id;
			$('.s_popup_delect,.issue_delect').hide();
			$.post(url, {
				"uid" : uid,
				"access_token" : access_token,
				"cid":cid,
				"id" : manage_activity_id,
			}, function(data) {
				
				if (data.status == 200) {
					successDialog("删除成功","该活动已从您的列表中移除！");
					$(lineId).remove();
				} else {
					errorDialog("删除失败",data.message);
				}
			});
		}
        /* 锁定活动编辑状态 */
        function lockActivity(type,id){
<%--         	var url= "<%=path%>/activity/lock";
        	$.post(url, {
        		"access_token" : access_token,
				"cid" : cid,
				"uid" : uid,
				"id" : id,
			}, function(data) {
				
				if(data.error_code==0){ --%>
					 if(type=="sys"){
		        		  window.location.href = "<%=path%>/api/bm/ui/createActivity2?type=edit&activity_id="+id;
		        	  }else if(type=="defined_pic"){
		        		  window.location.href = "<%=path%>/view/ui/photoAlbum?operationType=edit&type=activity&activity_id="+id;
		        	  }else if(type=="defined_text"){
		        		  window.location.href = "<%=path%>/view/ui/createModel?operationType=edit&type=activity&activity_id="+id;
		        	  }else if(type=="sys_invitation"){
		        		  window.location.href = "<%=path%>/api/bm/ui/invitation01?type=edit&activity_id="+id;
		        	  }
				/* }else{
					errorDialog(data.message,"");
				} 
			});*/
        }
        
        
        
        function hotActivityList(){
        	var url= "${pageContext.request.contextPath}/activity/ajaxActivityHotTemplateList";
        	$.post(url, {
				"access_token" : access_token,
			}, function(data) {
				
				if(data.status==200){
					hotActivityHtml(data.data);
				}else{
					
				}
			});
        }
        
        function activityhtml(data){
        	var html="";
        	for(var i=0;i<data.length;i++){
        		
        		var result=data[i];
        		console.log(result.id+"");
        		var receiveCouponNum=parseInt(result.receive_coupon)+parseInt(result.twiceReceive);
        		html+='<tr id="line'+result.id+'"><td><dl class="k_img_box">';
        		html+='<dt class="col-md-4"><img id="test_img'+i+'" style="width: 90px; height: 90px" src="'+result.headPic+'"/></dt>';
        		html+='<dd class="col-md-6" style="padding: 10px;"><h3><a href="<%=path%>/view/ui/activityDetail?type=0&activity_id='+result.id+'"><font color="#1ab394">'+result.name+'</font></a></h3>';
        		
				html += '<p>领取数:'+result.receiveCouponNum+'/总数:' + result.couponNumber + '</p>';
				html += '<p>' + (!StringEmpty(result.endTime) ? "":"有效期至"+formatDateTimeYMD(result.endTime)) + '</p></dd></dl></td>';
				html += '<td>';
				html += '<ol class="k_ol">';
				html += '</ol>转化率:'+(result.ratio!='' && result.ratio!=undefined? result.ratio:"0.0" )+'%</td>';
				html += '<td id="status'+result.id+'"' + getStaus(result.status)
						+ '<td>';
				html += '<ol><li>微博</li><li>微信</li><li>QQ</li><li>其他</li></ol>';
				html += '</td><td>';
				html += '<ol><li>' + result.weiboNum + '</li><li>'
						+ result.weixinNum + '</li><li>' + result.qqNum
						+ '</li><li>' + result.otherClick
						+ '</li></ol>';
				html += '</td><td>';
				html += '<ol><li>' + result.submitWeiboNum + '</li><li>'
						+ result.submitWeixinNum + '</li><li>'
						+ result.submitQqNum + '</li><li>'
						+ result.otherSubmit + '</li></ol>';
				html += '</td><td>';
				html += '<ol><li>' + result.weiboRatio + '%</li><li>'
						+ result.weixinRatio + '%</li><li>' + result.qqRatio
						+ '%</li><li>' + result.otherRatio
						+ '%</li></ol>';
				html += '</td><td>';
				html += '<ol class="s_none_line"><li><span>点击人数:</span>' + result.clickNum
						+ '</li><li><span>领券人数:</span>' + result.onceReceiveNum
						+ '</li><li><span>核销人数:</span>' + result.varicationNum
						+ '</li><li><span>转发次数:</span>' + result.transmitNum
						+ '</li></ol>';
				html += '</td><td>';
				html += '<ol class="s_none_line"><li><span>点击人数:</span>'+result.twiceClick+'</li><li><span>领券人数:</span>'+result.twiceReceive+'</li><li><span>核销人数:</span>'+result.twiceVarication+'</li><li><span>转发次数:</span>'+result.twiceTransmit+'</li></ol>';
				html += '</td><td>' + result.activityAmount + '</td>';
				html += '<td><shiro:hasPermission name="markting_activity_h5:start"><a href="javascript:;" id="manageId'+result.id+'" activityId="'+result.id+'" activityStatus="'+result.status+'"'
						+ (result.status == 1 ? "class='manageActivity'><font color='#1ab394'>停用</font>" : "class='manageActivity k_red'><font color='#ff7469'>启用</font>") + '</a> </shiro:hasPermission><br />';
				html += '<shiro:hasPermission name="markting_activity_h5:create"><a href="javascript:;" activity_type="'+result.activityType+'" activityId="'+result.id+'" class="copyActivity"><font color="#1ab394">复制</font></a></shiro:hasPermission><br />';
				html += '<shiro:hasPermission name="markting_activity_h5:update"><a href="javascript:;" activity_type="'+result.activityType+'" activityId="'+result.id+'" class="editActivity"><font color="#1ab394">编辑</font></a></shiro:hasPermission><br />';
				html += '<shiro:hasPermission name="markting_activity_h5:delete"><a href="javascript:;" activityId="'+result.id+'" class="deleteActivity"><font color="#1ab394">删除</font></a></shiro:hasPermission><br>';
				html +='<a href="javascript:;" id="shareManageId'+result.id+'" shareUrl="'+result.webUrl+'"  activityStatus="'+result.status+'" activityId="'+result.id+'" '+(result.status == 1 ? "class='shareActivity k_ty_btn'" : "class='shareActivity k_gray_enjoy k_ty_btn'")+'><font color="#1ab394">分享</font></a>';
				var reportUrl="<%=path%>/activity/detailReport?activityId="+result.id+"&activityName="+result.name;
				reportUrl=encodeURI(reportUrl);
				html += '<br/><shiro:hasPermission name="markting_activity_h5:report"><a href="'+reportUrl+'"><font color="#1ab394">报告</font></a></shiro:hasPermission></td></tr>';
			}

			$('#activity_list').html(html);
			imageLoadError();
		}

        function getStaus(status){
        	var result="";
        	switch(status)
        	{
        	case 0:
        		result="class=k_red><font color='#ff7469'>停用</font>";
        	  break;
        	case 1:
        		result='>正常';
        	  break;
        	case 2:
        		result="class=k_red><font color='#ff7469'>编辑</font>";
          	  break;
        	default:
        	}
        	return result;
        }
        
        
		function hotActivityHtml(data) {
			var html = "";
			for (var i = 0; i < data.length; i++) {
				html += '<div class="s_hot_con">';
				html += '<h4><a  model_type="'+data.type+'" class="model_title" id="'+data[i].id+'" href="javascript:;">' + (data[i].name!=null? data[i].name:"") + '</a></h4>';
				html += '<dl class="fix">';
				html += '<dt><img style="width: 75px; height: 110px" src="'+data[i].thumbnailPic+'"/></dt>';
				html += '<dd><ol>';
				html += '<li><span>累计使用：</span>' + data[i].useNum + '次</li>';
				html += '<li><span>平均转化率：</span>' + '0'
						+ '%</li>';
				html += '<li><span>单次高转化率：</span>' + '0'
						+ '%</li>';
				html += '<li><span>最高转化商机：</span>'
						+ data[i].maxWriteOff + '次</li>';
				html += '<li><span>最低转化商机：</span>'
						+ data[i].minWriteOff + '次</li>';
				html += '</ol></dd></dl></div>';
			}
			$('#hot_activity_list').html(html);
			imageLoadError();
		}

		  $(".m_xpages select").change(function(){
		 		pageSize = Number($(this).val());
		 		startIndex=0;
		 		activityList();
		 	});
		 	
		 	$(".m_xpages a.prev").click(function(){	 		
		 		if(currentPage > 1){
		 			currentPage--;
		 			startIndex -= pageSize;	 	
		 			activityList();
		 		}
		 	});
		 	
		 	$(".m_xpages a.next").click(function(){
		 		if(currentPage < pageCount){
		 			currentPage++;
		 			startIndex += pageSize;	
		 			activityList();
		 		}
		 	});
		 	
		 	$(".m_xpages :text").keyup(function(e){
				if(e.keyCode==13){
					var pageGo = $(this).val();
					if(/^[0-9]+$/.test(pageGo)){
						pageGo = Number(pageGo);
						if(pageGo<1 || pageGo>pageCount){
							showDialog('请输入合法页数');
						}else if(pageGo != currentPage){
							startIndex = (pageGo -1) * pageSize ;	
							activityList();
						}
					}else{
						showDialog('请输入合法页数');
					}
				}
			});
		function page(totalCount) {
			pageCount = totalCount/pageSize;
	 		if (totalCount % pageSize > 0)
	 			pageCount++;
	 		pageCount = parseInt(pageCount);
	 		currentPage =  startIndex / pageSize + 1;
	 		currentPage = parseInt(currentPage);
	 		
	 		if(currentPage == 1){
	 			$(".prev").addClass("pageDisable");
	 		}else{
	 			$(".prev").removeClass("pageDisable");
	 		}
	 		
	 		if(currentPage == pageCount || pageCount == 0){
	 			$(".next").addClass("pageDisable");
	 		}else{
	 			$(".next").removeClass("pageDisable");
	 		}
	 		if(pageSize>=totalCount){
	 			$("#input_page").attr("readonly","readonly");
	 		}else{
	 			$("#input_page").removeAttr("readonly");
	 		}
	 		
	 		
	 		$(".m_xpages>.mian>span:eq(1)").text('共'+totalCount+'条');
	 		$(".m_xpages>.mian>span:eq(2)").text(currentPage+'/'+pageCount+'页');
		}
		

		//判断字符串是否为空
		function StringEmpty(content) {
			if (content == undefined || content == "" || content == null) {
				return false;
			} else {
				return true;
			}
		}	
		
		function gotoLogin(){
			 $('#afreshLogin,.issue_delect1').hide(); 
			window.location.href="<%=path%>/ui/loginPwd";
		}
		
		function qiehuan(){
			$(event.srcElement).parent().parent().children('div').click();
		}
		
		
		function deletedDialog(){
			swal({
				  title: '您确定要删除此活动吗?',
				  text: "删除后将无法恢复，请谨慎操作！",
				  type: 'warning',
				  showCancelButton: true,
				  confirmButtonColor: '#d33',
				  cancelButtonColor: '#3085d6',
				  confirmButtonText: '删除',
				  cancelButtonText:'取消'
				}).then(function () {
					deleteActivity();
				})
		}
		
		function suspendDialog(){
			swal({
				  title: '您确定要停用此活动吗?',
				  text: "活动停用后用户将无法参加此活动！",
				  type: 'warning',
				  showCancelButton: true,
				  confirmButtonColor: '#d33',
				  cancelButtonColor: '#3085d6',
				  confirmButtonText: '停用',
				  cancelButtonText:'取消'
				}).then(function () {
					suspendActivity();
				})
		}
		
		function shareActivity(activityId){
			var url="<%=path%>/activity/ajaxGetActivityShortUrl";
    		$.post(url, {
    			"activityId" : activityId,
            }, function(data) {
    			if (data.status == 200) {
    				var shortUrl=data.data;
    				$('#qrcode').html("");
    				$("#shortUrl").val(shortUrl);
               	    jQuery('#qrcode').qrcode(shortUrl);
               	    $('#share_modal').modal('show');
    			}else if(data.error_code=="20028"){
    				loginDialog();
	        	}else{
	        		errorDialog(data.message);
	        	}
    		});
        }
		$(document).ready(function(){    
			var clipboard = new ClipboardJS('#btnCopy');
			   clipboard.on('success', function(e) {  
				   $('#share_modal').modal('hide');
				   successDialog("复制成功");
			   });  
			   clipboard.on('error', function(e) {  
				   $('#share_modal').modal('hide');
				   successDialog("复制失败！请手动复制");
			   });  
		}) 
		//跳转到群发短信
		function intentSocialSms(){
			window.location.href="<%=path%>/view/sms/choseSendObject?type=create&activityId="+manage_activity_id;
		}
	</script>

</body>
</html>